gh-125996: fix thread safety of ordered dict#133734
gh-125996: fix thread safety of ordered dict#133734kumaraditya303 merged 10 commits intopython:mainfrom
Conversation
colesbury
left a comment
There was a problem hiding this comment.
Would you please also provide some timing measurements for basic operations?
e87cd54 to
473cfa0
Compare
I added some benchmark for get/set operation to ftscaling and benchmarked it: index 1a59e25189d..20f15200051 100644
--- a/Tools/ftscalingbench/ftscalingbench.py
+++ b/Tools/ftscalingbench/ftscalingbench.py
@@ -28,6 +28,7 @@
import threading
import time
from operator import methodcaller
+from collections import OrderedDict
# The iterations in individual benchmarks are scaled by this factor.
WORK_SCALE = 100
@@ -43,6 +44,19 @@ def register_benchmark(func):
ALL_BENCHMARKS[func.__name__] = func
return func
+@register_benchmark
+def odict_get():
+ tab = OrderedDict((i, i) for i in range(100))
+ for i in range(1000 * WORK_SCALE):
+ tab.get(i % 100)
+
+@register_benchmark
+def odict_set():
+ tab = OrderedDict((i, i) for i in range(100))
+ for i in range(1000 * WORK_SCALE):
+ tab[i % 100] = i
+
+
@register_benchmark
def object_cfunction():
accu = 0
Results: ❯ ./python.exe Tools/ftscalingbench/ftscalingbench.py odict_get odict_set
Running benchmarks with 10 threads
odict_get 4.7x faster
odict_set 4.4x faster
|
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @kumaraditya303, I could not cleanly backport this to |
|
GH-140053 is a backport of this pull request to the 3.14 branch. |
pythonGH-133734) (cherry picked from commit 6481539) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
Uh oh!
There was an error while loading. Please reload this page.